<?php
namespace Admin\Controller;
use Admin\Controller\CommonController;
use Common\Model\AdModel;
use Think\Controller;

class CurlController extends  CommonController{


	public function index(){
		$this->display();
	}


	public function test(){
		$url = "http://roll.news.sina.com.cn/news/gnxw/gdxw1/index.shtml";
		import("Org.PhpQuery");
//		require THINK_PATH.'Library/Org/PhpQuery.class.php';

		\phpQuery::newDocumentFile($url);

		//分页地址获取


		//分页列表获取
		$list= pq(".list_009 li");
		$listUrl = array();
		foreach($list as $k => $v){
			$href = pq($v)->find('a')->attr('href');
			$title = pq($v)->find('a')->html();
			$listUrl[] = array(
				'title' => $title,
				'href'  => $href,
			);
		}

		//内容抓取
		$content = array();
		foreach($listUrl as $k => $v){
			\phpQuery::newDocumentFile($v['href']);
			$title = pq("#artibodyTitle")->html();
			$time = pq('navtimeSource')->html();
			$source = pq('navtimeSource span span a')->html();
			$body = pq('#artibody')->html();
			$content[] = array(
				'title' => $title,
				'time' => $time,
				'source' => $source,
				'body'   => $body,
			);
			var_dump($content);die;
		}

	}

}
